/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * Autogenerated by Thrift Compiler (0.9.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package backtype.storm.generated;

import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;

import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-2-22")
public class TopologySummary implements org.apache.thrift.TBase<TopologySummary, TopologySummary._Fields>, java.io.Serializable, Cloneable, Comparable<TopologySummary> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TopologySummary");

  private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField UPTIME_SECS_FIELD_DESC = new org.apache.thrift.protocol.TField("uptimeSecs", org.apache.thrift.protocol.TType.I32, (short)4);
  private static final org.apache.thrift.protocol.TField NUM_TASKS_FIELD_DESC = new org.apache.thrift.protocol.TField("numTasks", org.apache.thrift.protocol.TType.I32, (short)5);
  private static final org.apache.thrift.protocol.TField NUM_WORKERS_FIELD_DESC = new org.apache.thrift.protocol.TField("numWorkers", org.apache.thrift.protocol.TType.I32, (short)6);
  private static final org.apache.thrift.protocol.TField ERROR_INFO_FIELD_DESC = new org.apache.thrift.protocol.TField("errorInfo", org.apache.thrift.protocol.TType.STRING, (short)7);

  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new TopologySummaryStandardSchemeFactory());
    schemes.put(TupleScheme.class, new TopologySummaryTupleSchemeFactory());
  }

  private String id; // required
  private String name; // required
  private String status; // required
  private int uptimeSecs; // required
  private int numTasks; // required
  private int numWorkers; // required
  private String errorInfo; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    ID((short)1, "id"),
    NAME((short)2, "name"),
    STATUS((short)3, "status"),
    UPTIME_SECS((short)4, "uptimeSecs"),
    NUM_TASKS((short)5, "numTasks"),
    NUM_WORKERS((short)6, "numWorkers"),
    ERROR_INFO((short)7, "errorInfo");

    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

    static {
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // ID
          return ID;
        case 2: // NAME
          return NAME;
        case 3: // STATUS
          return STATUS;
        case 4: // UPTIME_SECS
          return UPTIME_SECS;
        case 5: // NUM_TASKS
          return NUM_TASKS;
        case 6: // NUM_WORKERS
          return NUM_WORKERS;
        case 7: // ERROR_INFO
          return ERROR_INFO;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    public static _Fields findByName(String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final String _fieldName;

    _Fields(short thriftId, String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __UPTIMESECS_ISSET_ID = 0;
  private static final int __NUMTASKS_ISSET_ID = 1;
  private static final int __NUMWORKERS_ISSET_ID = 2;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.ERROR_INFO};
  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.UPTIME_SECS, new org.apache.thrift.meta_data.FieldMetaData("uptimeSecs", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.NUM_TASKS, new org.apache.thrift.meta_data.FieldMetaData("numTasks", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.NUM_WORKERS, new org.apache.thrift.meta_data.FieldMetaData("numWorkers", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.ERROR_INFO, new org.apache.thrift.meta_data.FieldMetaData("errorInfo", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TopologySummary.class, metaDataMap);
  }

  public TopologySummary() {
  }

  public TopologySummary(
    String id,
    String name,
    String status,
    int uptimeSecs,
    int numTasks,
    int numWorkers)
  {
    this();
    this.id = id;
    this.name = name;
    this.status = status;
    this.uptimeSecs = uptimeSecs;
    set_uptimeSecs_isSet(true);
    this.numTasks = numTasks;
    set_numTasks_isSet(true);
    this.numWorkers = numWorkers;
    set_numWorkers_isSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TopologySummary(TopologySummary other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.is_set_id()) {
      this.id = other.id;
    }
    if (other.is_set_name()) {
      this.name = other.name;
    }
    if (other.is_set_status()) {
      this.status = other.status;
    }
    this.uptimeSecs = other.uptimeSecs;
    this.numTasks = other.numTasks;
    this.numWorkers = other.numWorkers;
    if (other.is_set_errorInfo()) {
      this.errorInfo = other.errorInfo;
    }
  }

  public TopologySummary deepCopy() {
    return new TopologySummary(this);
  }

  @Override
  public void clear() {
    this.id = null;
    this.name = null;
    this.status = null;
    set_uptimeSecs_isSet(false);
    this.uptimeSecs = 0;
    set_numTasks_isSet(false);
    this.numTasks = 0;
    set_numWorkers_isSet(false);
    this.numWorkers = 0;
    this.errorInfo = null;
  }

  public String get_id() {
    return this.id;
  }

  public void set_id(String id) {
    this.id = id;
  }

  public void unset_id() {
    this.id = null;
  }

  /** Returns true if field id is set (has been assigned a value) and false otherwise */
  public boolean is_set_id() {
    return this.id != null;
  }

  public void set_id_isSet(boolean value) {
    if (!value) {
      this.id = null;
    }
  }

  public String get_name() {
    return this.name;
  }

  public void set_name(String name) {
    this.name = name;
  }

  public void unset_name() {
    this.name = null;
  }

  /** Returns true if field name is set (has been assigned a value) and false otherwise */
  public boolean is_set_name() {
    return this.name != null;
  }

  public void set_name_isSet(boolean value) {
    if (!value) {
      this.name = null;
    }
  }

  public String get_status() {
    return this.status;
  }

  public void set_status(String status) {
    this.status = status;
  }

  public void unset_status() {
    this.status = null;
  }

  /** Returns true if field status is set (has been assigned a value) and false otherwise */
  public boolean is_set_status() {
    return this.status != null;
  }

  public void set_status_isSet(boolean value) {
    if (!value) {
      this.status = null;
    }
  }

  public int get_uptimeSecs() {
    return this.uptimeSecs;
  }

  public void set_uptimeSecs(int uptimeSecs) {
    this.uptimeSecs = uptimeSecs;
    set_uptimeSecs_isSet(true);
  }

  public void unset_uptimeSecs() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __UPTIMESECS_ISSET_ID);
  }

  /** Returns true if field uptimeSecs is set (has been assigned a value) and false otherwise */
  public boolean is_set_uptimeSecs() {
    return EncodingUtils.testBit(__isset_bitfield, __UPTIMESECS_ISSET_ID);
  }

  public void set_uptimeSecs_isSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __UPTIMESECS_ISSET_ID, value);
  }

  public int get_numTasks() {
    return this.numTasks;
  }

  public void set_numTasks(int numTasks) {
    this.numTasks = numTasks;
    set_numTasks_isSet(true);
  }

  public void unset_numTasks() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __NUMTASKS_ISSET_ID);
  }

  /** Returns true if field numTasks is set (has been assigned a value) and false otherwise */
  public boolean is_set_numTasks() {
    return EncodingUtils.testBit(__isset_bitfield, __NUMTASKS_ISSET_ID);
  }

  public void set_numTasks_isSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __NUMTASKS_ISSET_ID, value);
  }

  public int get_numWorkers() {
    return this.numWorkers;
  }

  public void set_numWorkers(int numWorkers) {
    this.numWorkers = numWorkers;
    set_numWorkers_isSet(true);
  }

  public void unset_numWorkers() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __NUMWORKERS_ISSET_ID);
  }

  /** Returns true if field numWorkers is set (has been assigned a value) and false otherwise */
  public boolean is_set_numWorkers() {
    return EncodingUtils.testBit(__isset_bitfield, __NUMWORKERS_ISSET_ID);
  }

  public void set_numWorkers_isSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __NUMWORKERS_ISSET_ID, value);
  }

  public String get_errorInfo() {
    return this.errorInfo;
  }

  public void set_errorInfo(String errorInfo) {
    this.errorInfo = errorInfo;
  }

  public void unset_errorInfo() {
    this.errorInfo = null;
  }

  /** Returns true if field errorInfo is set (has been assigned a value) and false otherwise */
  public boolean is_set_errorInfo() {
    return this.errorInfo != null;
  }

  public void set_errorInfo_isSet(boolean value) {
    if (!value) {
      this.errorInfo = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case ID:
      if (value == null) {
        unset_id();
      } else {
        set_id((String)value);
      }
      break;

    case NAME:
      if (value == null) {
        unset_name();
      } else {
        set_name((String)value);
      }
      break;

    case STATUS:
      if (value == null) {
        unset_status();
      } else {
        set_status((String)value);
      }
      break;

    case UPTIME_SECS:
      if (value == null) {
        unset_uptimeSecs();
      } else {
        set_uptimeSecs((Integer)value);
      }
      break;

    case NUM_TASKS:
      if (value == null) {
        unset_numTasks();
      } else {
        set_numTasks((Integer)value);
      }
      break;

    case NUM_WORKERS:
      if (value == null) {
        unset_numWorkers();
      } else {
        set_numWorkers((Integer)value);
      }
      break;

    case ERROR_INFO:
      if (value == null) {
        unset_errorInfo();
      } else {
        set_errorInfo((String)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case ID:
      return get_id();

    case NAME:
      return get_name();

    case STATUS:
      return get_status();

    case UPTIME_SECS:
      return Integer.valueOf(get_uptimeSecs());

    case NUM_TASKS:
      return Integer.valueOf(get_numTasks());

    case NUM_WORKERS:
      return Integer.valueOf(get_numWorkers());

    case ERROR_INFO:
      return get_errorInfo();

    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case ID:
      return is_set_id();
    case NAME:
      return is_set_name();
    case STATUS:
      return is_set_status();
    case UPTIME_SECS:
      return is_set_uptimeSecs();
    case NUM_TASKS:
      return is_set_numTasks();
    case NUM_WORKERS:
      return is_set_numWorkers();
    case ERROR_INFO:
      return is_set_errorInfo();
    }
    throw new IllegalStateException();
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof TopologySummary)
      return this.equals((TopologySummary)that);
    return false;
  }

  public boolean equals(TopologySummary that) {
    if (that == null)
      return false;

    boolean this_present_id = true && this.is_set_id();
    boolean that_present_id = true && that.is_set_id();
    if (this_present_id || that_present_id) {
      if (!(this_present_id && that_present_id))
        return false;
      if (!this.id.equals(that.id))
        return false;
    }

    boolean this_present_name = true && this.is_set_name();
    boolean that_present_name = true && that.is_set_name();
    if (this_present_name || that_present_name) {
      if (!(this_present_name && that_present_name))
        return false;
      if (!this.name.equals(that.name))
        return false;
    }

    boolean this_present_status = true && this.is_set_status();
    boolean that_present_status = true && that.is_set_status();
    if (this_present_status || that_present_status) {
      if (!(this_present_status && that_present_status))
        return false;
      if (!this.status.equals(that.status))
        return false;
    }

    boolean this_present_uptimeSecs = true;
    boolean that_present_uptimeSecs = true;
    if (this_present_uptimeSecs || that_present_uptimeSecs) {
      if (!(this_present_uptimeSecs && that_present_uptimeSecs))
        return false;
      if (this.uptimeSecs != that.uptimeSecs)
        return false;
    }

    boolean this_present_numTasks = true;
    boolean that_present_numTasks = true;
    if (this_present_numTasks || that_present_numTasks) {
      if (!(this_present_numTasks && that_present_numTasks))
        return false;
      if (this.numTasks != that.numTasks)
        return false;
    }

    boolean this_present_numWorkers = true;
    boolean that_present_numWorkers = true;
    if (this_present_numWorkers || that_present_numWorkers) {
      if (!(this_present_numWorkers && that_present_numWorkers))
        return false;
      if (this.numWorkers != that.numWorkers)
        return false;
    }

    boolean this_present_errorInfo = true && this.is_set_errorInfo();
    boolean that_present_errorInfo = true && that.is_set_errorInfo();
    if (this_present_errorInfo || that_present_errorInfo) {
      if (!(this_present_errorInfo && that_present_errorInfo))
        return false;
      if (!this.errorInfo.equals(that.errorInfo))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    List<Object> list = new ArrayList<Object>();

    boolean present_id = true && (is_set_id());
    list.add(present_id);
    if (present_id)
      list.add(id);

    boolean present_name = true && (is_set_name());
    list.add(present_name);
    if (present_name)
      list.add(name);

    boolean present_status = true && (is_set_status());
    list.add(present_status);
    if (present_status)
      list.add(status);

    boolean present_uptimeSecs = true;
    list.add(present_uptimeSecs);
    if (present_uptimeSecs)
      list.add(uptimeSecs);

    boolean present_numTasks = true;
    list.add(present_numTasks);
    if (present_numTasks)
      list.add(numTasks);

    boolean present_numWorkers = true;
    list.add(present_numWorkers);
    if (present_numWorkers)
      list.add(numWorkers);

    boolean present_errorInfo = true && (is_set_errorInfo());
    list.add(present_errorInfo);
    if (present_errorInfo)
      list.add(errorInfo);

    return list.hashCode();
  }

  @Override
  public int compareTo(TopologySummary other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(is_set_id()).compareTo(other.is_set_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_id()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_name()).compareTo(other.is_set_name());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_name()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_status()).compareTo(other.is_set_status());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_status()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_uptimeSecs()).compareTo(other.is_set_uptimeSecs());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_uptimeSecs()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.uptimeSecs, other.uptimeSecs);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_numTasks()).compareTo(other.is_set_numTasks());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_numTasks()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.numTasks, other.numTasks);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_numWorkers()).compareTo(other.is_set_numWorkers());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_numWorkers()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.numWorkers, other.numWorkers);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_errorInfo()).compareTo(other.is_set_errorInfo());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_errorInfo()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errorInfo, other.errorInfo);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("TopologySummary(");
    boolean first = true;

    sb.append("id:");
    if (this.id == null) {
      sb.append("null");
    } else {
      sb.append(this.id);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("name:");
    if (this.name == null) {
      sb.append("null");
    } else {
      sb.append(this.name);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("status:");
    if (this.status == null) {
      sb.append("null");
    } else {
      sb.append(this.status);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("uptimeSecs:");
    sb.append(this.uptimeSecs);
    first = false;
    if (!first) sb.append(", ");
    sb.append("numTasks:");
    sb.append(this.numTasks);
    first = false;
    if (!first) sb.append(", ");
    sb.append("numWorkers:");
    sb.append(this.numWorkers);
    first = false;
    if (is_set_errorInfo()) {
      if (!first) sb.append(", ");
      sb.append("errorInfo:");
      if (this.errorInfo == null) {
        sb.append("null");
      } else {
        sb.append(this.errorInfo);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    if (!is_set_id()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'id' is unset! Struct:" + toString());
    }

    if (!is_set_name()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' is unset! Struct:" + toString());
    }

    if (!is_set_status()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString());
    }

    if (!is_set_uptimeSecs()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'uptimeSecs' is unset! Struct:" + toString());
    }

    if (!is_set_numTasks()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'numTasks' is unset! Struct:" + toString());
    }

    if (!is_set_numWorkers()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'numWorkers' is unset! Struct:" + toString());
    }

    // check for sub-struct validity
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class TopologySummaryStandardSchemeFactory implements SchemeFactory {
    public TopologySummaryStandardScheme getScheme() {
      return new TopologySummaryStandardScheme();
    }
  }

  private static class TopologySummaryStandardScheme extends StandardScheme<TopologySummary> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TopologySummary struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // ID
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.id = iprot.readString();
              struct.set_id_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.name = iprot.readString();
              struct.set_name_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // STATUS
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.status = iprot.readString();
              struct.set_status_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // UPTIME_SECS
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.uptimeSecs = iprot.readI32();
              struct.set_uptimeSecs_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // NUM_TASKS
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.numTasks = iprot.readI32();
              struct.set_numTasks_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // NUM_WORKERS
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.numWorkers = iprot.readI32();
              struct.set_numWorkers_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // ERROR_INFO
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.errorInfo = iprot.readString();
              struct.set_errorInfo_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, TopologySummary struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.id != null) {
        oprot.writeFieldBegin(ID_FIELD_DESC);
        oprot.writeString(struct.id);
        oprot.writeFieldEnd();
      }
      if (struct.name != null) {
        oprot.writeFieldBegin(NAME_FIELD_DESC);
        oprot.writeString(struct.name);
        oprot.writeFieldEnd();
      }
      if (struct.status != null) {
        oprot.writeFieldBegin(STATUS_FIELD_DESC);
        oprot.writeString(struct.status);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(UPTIME_SECS_FIELD_DESC);
      oprot.writeI32(struct.uptimeSecs);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(NUM_TASKS_FIELD_DESC);
      oprot.writeI32(struct.numTasks);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(NUM_WORKERS_FIELD_DESC);
      oprot.writeI32(struct.numWorkers);
      oprot.writeFieldEnd();
      if (struct.errorInfo != null) {
        if (struct.is_set_errorInfo()) {
          oprot.writeFieldBegin(ERROR_INFO_FIELD_DESC);
          oprot.writeString(struct.errorInfo);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class TopologySummaryTupleSchemeFactory implements SchemeFactory {
    public TopologySummaryTupleScheme getScheme() {
      return new TopologySummaryTupleScheme();
    }
  }

  private static class TopologySummaryTupleScheme extends TupleScheme<TopologySummary> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TopologySummary struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      oprot.writeString(struct.id);
      oprot.writeString(struct.name);
      oprot.writeString(struct.status);
      oprot.writeI32(struct.uptimeSecs);
      oprot.writeI32(struct.numTasks);
      oprot.writeI32(struct.numWorkers);
      BitSet optionals = new BitSet();
      if (struct.is_set_errorInfo()) {
        optionals.set(0);
      }
      oprot.writeBitSet(optionals, 1);
      if (struct.is_set_errorInfo()) {
        oprot.writeString(struct.errorInfo);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TopologySummary struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      struct.id = iprot.readString();
      struct.set_id_isSet(true);
      struct.name = iprot.readString();
      struct.set_name_isSet(true);
      struct.status = iprot.readString();
      struct.set_status_isSet(true);
      struct.uptimeSecs = iprot.readI32();
      struct.set_uptimeSecs_isSet(true);
      struct.numTasks = iprot.readI32();
      struct.set_numTasks_isSet(true);
      struct.numWorkers = iprot.readI32();
      struct.set_numWorkers_isSet(true);
      BitSet incoming = iprot.readBitSet(1);
      if (incoming.get(0)) {
        struct.errorInfo = iprot.readString();
        struct.set_errorInfo_isSet(true);
      }
    }
  }

}

